﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp2LogicalResource;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        // 获取资源
        Brush brush = (Brush)FindResource("brush1");
        Brush brush1 = (Brush)TryFindResource("brush1");
        Brush brush2 = (Brush)this.Resources["brush1"];
        // 添加或删除资源
        this.Resources.Add("brush2", new SolidColorBrush(
            Color.FromRgb(200, 10, 150)));
        //this.Resources.Remove("brush1");
        // 修改资源
        var brush3 = (LinearGradientBrush)this.Resources["brush1"];
        brush3.GradientStops.Add(new GradientStop(Colors.Blue, .5));
    }
}